home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / dispio1.aqm / dispio1.asm
Assembly Source File  |  1985-06-19  |  5KB  |  142 lines

  1. PAGE 60,132
  2. TITLE DISPIO - SUBROUTINE TO PERFORM DIRECT SCREEN I/O
  3. ;                         Listing 3
  4. ;                  C to Assembly Interface
  5. ;   Computer Language, Vol. 2, No. 2 (February, 1985), pp. 49-59
  6. ;
  7. ;Interfacing C to access architecture dependent capabilities 
  8. ;
  9. ;  #define MAX 8
  10. ;  char retvals [MAX] /* used by 3 functions */
  11. ;           /* (1) - read cursor position; retvals[0-1] = current cursor mode */
  12. ;           /*         retvals[3] = col, retvals[2] = row */
  13. ;           /* (2) - read light pen position  */
  14. ;           /*         retvals[0] = active(1)/inactive(0) */
  15. ;           /*         retvals[2-3] = pixel column, retvals[4]=raster line */
  16. ;           /*         retvals[6] = row, retvals[7] = col */
  17. ;           /* (3) - get state; retvals[0] = cols, retvals[1] = mode */
  18. ;           /*         retvals[2] = page */ 
  19. ;
  20. ;   setmode - dispio(mode) ;
  21. ;   set cursor type - dispio(set_curs_type,type) ;
  22. ;   set cursor position - dispio(set_cursor,page<<8,row<<8+col) ;
  23. ;   read cursor position - dispio(read_cursor_position,page<<8,retvals) ;
  24. ;   read light pen position - dispio(read_pen,retvals) ;
  25. ;   select active page - dispio(select_page+new_page_value) ;
  26. ;   scroll active page up - dispio(scroll_up+number_of_lines,page<<8,
  27. ;                                  lrow<<8+lcol, rrow<<8+rcol) ;
  28. ;   scroll active page down - dispio(scroll_down+number_of_lines,page<<8,
  29. ;                                    lrow<<8+lcol,rrow<<8+rcol) ;
  30. ;   get attribute character at current cursor pos - dispio(readac,page<<8) ;
  31. ;     returns attribute character as function value - high byte attribute,
  32. ;     low byte character
  33. ;   write attribute character at current cursor position - dispio(writeac+char,
  34. ;            page<<8+attribute, repeat count)
  35. ;   write character - dispio(write_char+character,page<<8,repeat count) ;
  36. ;   set color palette - dispio(set_pallette,pallette<<8+color_value) ;
  37. ;   write dot - dispio(write_dot+color,col,row) ;
  38. ;   read dot - dispio(read_dot,col,row)
  39. ;              dot read returned as low byte of function value
  40. ;   write teletype - dispio(write_teletype+char,(page<<8)+color) ;
  41. ;   get state - dispio(get_state,retval) 
  42. ;
  43. ;**************************************************************
  44. ;
  45. ;   Surrounded each INT 10H with a PUSH BP / POP BP pair.  This may not be
  46. ;   necessary in every case, but it is for SCROLL, and it makes the others
  47. ;   safe.
  48. ;
  49. ;   L. Paper
  50. ;   6/17/85
  51. ;
  52. DGROUP  GROUP  DATA
  53. DATA    SEGMENT WORD PUBLIC 'DATA'
  54.         ASSUME  DS:DGROUP
  55. CASE_TABLE DW SETMODE,CURSTYPE,SETCURS,READCURS,READPEN,SETMODE
  56.            DW SCROLL,SCROLL,READAC,WRITEAC,WRITEAC,READAC,WRITEDOT
  57.            DW WRITEDOT,READAC,STATE
  58. ; case table uses 16 words
  59. RLAYOUT  STRUC        ; Return address space layout
  60. RAX     DW    ?       
  61. RBX     DW    ?
  62. RCX     DW    ?
  63. RDX     DW    ?
  64. RLAYOUT ENDS
  65. DATA    ENDS
  66. ;
  67. PGROUP  GROUP  PROG
  68. PROG    SEGMENT  BYTE  PUBLIC 'PROG'
  69.         ASSUME   CS:PGROUP
  70.         PUBLIC   DISPIO
  71. ;
  72. DISPIO  PROC    NEAR
  73.         POP     SI
  74.         POP     AX
  75.         MOV     BL,AH
  76.         XOR     BH,BH
  77.         CMP     BL,15             ; INVALID FUNCTION CODE ?
  78.         JA      ERROR
  79.         SHL     BX,1
  80.         JMP     CASE_TABLE[BX]
  81. ;
  82. ERROR:  MOV     AX,-1
  83.         JMP     SI
  84. ;
  85. SETCURS:   POP    BX
  86.            POP    DX
  87. SETMODE:   PUSH   BP          ;L.P.
  88.            INT    10H
  89.            POP    BP          ;L.P.
  90.            JMP    SI
  91. ;
  92. READCURS:  POP    BX
  93.            PUSH   BP          ;L.P.
  94.            INT    10H
  95.            POP    BP          ;L.P.
  96.            POP    DI
  97.            MOV    [DI].RAX,CX
  98.            MOV    [DI].RBX,DX
  99.            JMP    SI
  100. ;
  101. SCROLL:    POP    BX
  102. WRITEDOT:  POP    CX
  103.            POP    DX
  104.            PUSH   BP          ;L.P.
  105.            INT    10H
  106.            POP    BP          ;L.P.
  107.            JMP    SI
  108. ;
  109. READAC:    POP    BX
  110.            PUSH   BP          ;L.P.
  111.            INT    10H
  112.            POP    BP          ;L.P.
  113.            JMP    SI
  114. ;
  115. WRITEAC:   POP    BX
  116. CURSTYPE:  POP    CX
  117.            PUSH   BP          ;L.P.
  118.            INT    10H
  119.            POP    BP          ;L.P.
  120.            JMP    SI
  121. ;
  122. STATE:     PUSH   BP          ;L.P.
  123.            INT    10H
  124.            POP    BP          ;L.P.
  125.            POP    DI
  126.            MOV    [DI].RAX,AX
  127.            MOV    [DI].RBX,BX
  128.            JMP    SI
  129. ;
  130. READPEN:   PUSH   BP          ;L.P.
  131.            INT    10H
  132.            POP    BP          ;L.P.
  133.            POP    DI
  134.            MOV    [DI].RAX,AX
  135.            MOV    [DI].RBX,BX
  136.            MOV    [DI].RCX,CX
  137.            MOV    [DI].RDX,DX
  138.            JMP    SI
  139. DISPIO  ENDP
  140. PROG    ENDS
  141.         END
  142.